package chapter5.No5_1_定时器Timer的使用.demo4;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

/**
 * Timer中允许有多个TimerTask任务及延时的测试
 * <p>
 * 延时是因为timerTask是以队列的方式一个个被顺序的执行
 * Created by Administrator on 2016/11/24.
 */
public class Main {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.SECOND, 5);
        Date d = c.getTime();
        System.out.println("b预计时间："+d);

        MyTask m1 = new MyTask();
        My2Task m2 = new My2Task();

        Timer timer = new Timer();
        timer.schedule(m1, new Date());
        timer.schedule(m2, d);

    }
}
